home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / PROG_TOO / C013.ZIP / TEST.C < prev    next >
Text File  |  1990-01-19  |  364b  |  23 lines

  1. int test, base;
  2.  
  3. main()        /* RatC example program  */
  4. {
  5.     test=99;
  6.     base=8;
  7.     prnum(test,base);
  8.     putchar('\n');
  9. }
  10.  
  11. prnum(num,base)    /* print "num" in "base" */
  12. int num,base;
  13. {
  14.     int quot,rem;
  15.  
  16.     if (base<2|base>10) return;
  17.     if (num<0) {putchar('-'); num= -num; }
  18.     quot=num/base;
  19.     rem=num%base;
  20.     if (quot!=0) prnum(quot,base);
  21.     putchar(rem+'0');
  22. }
  23.